<template>
	<view>
		<view :class="item.clicked==true?'user-card-clicked':'user-card'" v-for="(item,index) in dataList">

			<view class="cover" @click.stop="selected(index,item)">


				<view class="info">
					<view class="text-1" style="margin-top: 19px;margin-bottom: 10px;">{{item.serverName}}</view>
					<view class="text-2">{{item.serverDescribe}}</view>
					<view class="text-2">{{item.uniqueContent}}</view>
					<view class="price" style="margin-top: 10px;margin-bottom: 19px;">￥{{item.serverPrice}}<text
							class="before" style="font-size: 12px;"></text></view>
				</view>
				<image class="img"
					:src="item.serverImage||'@appstatic/img/my/appoint_img_small.png'" />

			</view>



			<view v-if="item.clicked == true">
				<view class="editView" v-if="item.editshow==true">
					<view class="inputView">
						<input class="input" type="text" v-model="item.edit" maxlength="6" placeholder="请输入"
							@input="myCommentInput($event,index)" />
						<view class="inputNum">{{remnant}}/6</view>
					</view>


					<view class="confirm" v-if="item.edit == ''" @click.stop="remarks(item)">确定</view>

					<view class="confirm_clickable" v-else @click.stop="remarks(item)">确定</view>
				</view>
			</view>
		</view>
		<view v-if="dataList.length==0">
			<view class='img-box'>
				<image class='emptyImage' mode="aspectFit"
					src='@appstatic/img/my/my_order_no_data.png'></image>
				<view class='text'>暂无数据</view>
			</view>
		</view>


	</view>
</template>

<script>
	export default {
		name: "carSeries",
		props: {
			individuationList: {
				type: Array,
				default: () => {
					return []
				}
			}

		},
		data() {
			return {
				remnant: '0'
			};
		},

		computed: {

			dataList: {
				get() {
					for (var i = 0; i < this.individuationList.length; i++) {
						if (this.individuationList[i].clicked == 1) {
							this.$emit('individuationItem_watch', this.individuationList[i])
						}
					}
					return this.individuationList
				},
				set(v) {

				}

			}
		},
		methods: {
			selected: function(index) {
				for (var i = 0; i < this.dataList.length; i++) {
					if (index == i) {
						this.dataList[i].clicked = !this.dataList[i].clicked
						if (this.dataList[i].clicked == 1) {
							this.dataList[i].editshow = true
							this.dataList[i].edit = this.dataList[i].uniqueContent
						}
						this.$emit('individuationItem', this.dataList[i])
					} else {
						this.dataList[i].clicked = 0
					}

				}

			},
			remarks: function(item) {
				if (item.edit == '') {
					setTimeout(() => {
						uni.showToast({
							title: "请输入个性化内容",
							duration: 3000,
							icon: 'none'
						})
					}, 500)
					return
				}
				item.uniqueContent = item.edit
				item.edit = ""
				item.editshow = false
				this.$emit('individuationItem', item)

			},
			myCommentInput: function(e,index) {
				
 				     var str = e.detail.value.replace(/[\uD83C|\uD83D|\uD83E][\uDC00-\uDFFF][\u200D|\uFE0F]|[\uD83C|\uD83D|\uD83E][\uDC00-\uDFFF]|[0-9|*|#]\uFE0F\u20E3|[0-9|#]\u20E3|[\u203C-\u3299]\uFE0F\u200D|[\u203C-\u3299]\uFE0F|[\u2122-\u2B55]|\u303D|[\A9|\AE]\u3030|\uA9|\uAE|\u3030/ig, "");     // 表情的正则表达式 
				 debugger
 				  //重新赋值给input
				  this.$nextTick(() => {
				    this.dataList[index].edit= str;
				  });
				
				this.remnant = e.detail.value.length
				 
			}
		}
	}
</script>

<style lang='scss' scoped>
	.editView {
		width: 100%;
		height: 45px;
		background-color: #EA5404;
		display: flex;
		flex-direction: row;
		align-items: center;





	}

	.inputView {
		flex: 1;
		background: #FFFFFF;
		border-radius: 4rpx;
		height: 68rpx;
		margin-left: 5px;
		display: flex;
		flex-direction: row;
		justify-content: space-between;
		align-items: center;
		 
	}

	.input {
		line-height: 68rpx;
		padding-left: 32rpx;
		height: 68rpx;
	}

	.inputNum {
		font-family: 'Noto Sans CJK SC';
		font-style: normal;
		font-weight: 400;
		font-size: 14px;
		line-height: 21px;
		display: flex;
		align-items: center;
		color: #ADB0AE;
		margin-right: 10px;
	}

	.confirm {
		font-size: 32rpx;
		line-height: 44rpx;
		color: #FF965E;
		align-self: center;
		margin-right: 15px;
		margin-left: 15px;

	}
	.confirm_clickable {
		font-size: 32rpx;
		line-height: 44rpx;
		color: #ffffff;
		align-self: center;
		margin-right: 15px;
		margin-left: 15px;
	
	}

	.user-card-clicked {
		width: calc(100% - 30px);
		margin-top: 20rpx;
		/* height: 120px; */
		margin-left: 15px;
		clip-path: polygon(15px 0, calc(100% - 15px) 0,

				100% 0px, 100% calc(100% - 15px),

				calc(100% - 15px) 100%, 0px 100%,

				0 calc(100% - 15px), 0 15px);

		background: linear-gradient(-45deg, #EA5404 10px, #EDEDED 0) bottom right,

			linear-gradient(45deg, #EA5404 0px, #EDEDED 0) bottom left,

			linear-gradient(135deg, #EA5404 10px, #EDEDED 0) top left,

			linear-gradient(-135deg, #EA5404 0px, #EDEDED 0) top right;

		background-size: 52% 52%;
		background-repeat: no-repeat;
		border: solid 2px #EA5404;


	}

	.user-card {
		width: calc(100% - 30px);
		margin-top: 20rpx;
		/* height: 120px; */
		margin-left: 15px;
		clip-path: polygon(15px 0, calc(100% - 15px) 0,

				100% 0px, 100% calc(100% - 15px),

				calc(100% - 15px) 100%, 0px 100%,

				0 calc(100% - 15px), 0 15px);

		background: linear-gradient(-45deg, #EDEDED 10px, #EDEDED 0) bottom right,

			linear-gradient(45deg, #EDEDED 0px, #EDEDED 0) bottom left,

			linear-gradient(135deg, #EDEDED 10px, #EDEDED 0) top left,

			linear-gradient(-135deg, #EDEDED 0px, #EDEDED 0) top right;

		background-size: 52% 52%;
		background-repeat: no-repeat;
		border: solid 2px #EDEDED;


	}

	.cover {
		width: 100%;
		height: 120px;
		z-index: 2;
		display: flex;

	}



	.info {
		width: calc(100% - 180px);
		height: 100%;
		display: flex;
		flex-direction: column;
		align-items: flex-start;
		justify-content: center;
		margin-left: 30px;
	}

	.text-1 {
		font-weight: 700;
		font-size: 34rpx;
		line-height: 36rpx;
		display: flex;
		align-items: center;
		color: #3D3A3A;
	}

	.text-2 {
		font-weight: 400;
		font-size: 24rpx;
		line-height: 36rpx;
		display: flex;
		align-items: center;
		color: #333333;
		opacity: 0.4;
	}


	.price {
		font-weight: 400;
		font-size: 28rpx;
		line-height: 30rpx;
		display: flex;
		align-items: center;
		color: #3D3A3A;
	}


	.before:before {
		content: " ";
		white-space: pre;

	}

	.before1:before {
		content: "   ";
		white-space: pre;

	}

	.img {
		width: 180px;
		height: 120px;
		clip-path: polygon(0px 0, calc(100% - 15px) 0,

				100% 0px, 100% calc(100% - 15px),

				calc(100% - 15px) 100%, 0px 100%,

				0 calc(100% - 15px), 0 15px);

	}

	.img-box {
	  width: 100vw;
	  /* margin-left: calc(50% - 150rpx); */
	  display: flex;
	  flex-direction: column;
	  align-items: center;
	}
	.emptyImage{
	  width: 300rpx;
	  height: 300rpx;
	  margin-top: 50px;
	}
	.text {
	  text-align: center;
	  font-size: 28rpx;
	  line-height: 5px;
	  color: #ADB0AE;
	}
</style>
